<?php
abstract class Apps_Db_Table_Abstract extends Zend_Db_Table_Abstract {
    const FILTER_AUTO_KEY = 'auto-key';

    public function getName() { return $this->_name; }

    public function safelyDelete($where) {
    	return parent::delete($where);
    }
    public function safelyInsert(array $data, $keyFilters=null, $exclude=false) {
        if(null === $keyFilters) {
            $keyFilters = $this->_getCols();
        }

        $data = $this->arrayFilter($data, $keyFilters, $exclude);

        return parent::insert($data);
    }
    public function safelyUpdate(array $data, $where, $keyFilters=null, $exclude=false) {
        if(null === $keyFilters) {
            $keyFilters = $this->_getCols();
        }
        $data = $this->arrayFilter($data, $keyFilters, $exclude);
        return parent::update($data, $where);
    }

// ARRAY FILTER
    public function arrayFilter($array, $keys, $exclude=false) {
        // Special-key specified: all table-columns
        if($keys instanceof self) {
            $keys = $keys->_getCols();
        }
        $dFilter = new Model_Tool_DataFilter();
        return $dFilter->arrayFilter($array, $keys, $exclude);
    }


// LAZY HELPER
    public function field($field, $where) {
    }

// TRANSLATE , get lang
    public function getLang() {
        $session = new Zend_Session_Namespace('sessionLanguage');
        return $session->lang;
    }
}
